package com.jz.service.impl;

import com.jz.entity.PageBean;
import com.jz.entity.User;
import com.jz.dao.UserDao;
import com.jz.dao.impl.UserDaoImpl;
import com.jz.service.UserService;

import java.util.List;


/**
 * @ClassName UserServiceImpl
 * @Description
 * @Author MR_Liu
 * @Date 2021/7/22 0022 11:15
 * @Version 1.0
 */
public class UserServiceImpl implements UserService {
    UserDao userDao = new UserDaoImpl();
    //登录
    @Override
    public User login(String username, String password) {
        return userDao.login(username,password);
    }

    @Override
    public PageBean<User> queryUser(String name, int pageSize, int curPage) {
        //获取分页显示的数据
        List<User> list = userDao.queryUser(name, pageSize, curPage);
        //获取记录数
        int count = userDao.queryUserCount(name);
        PageBean<User> pb = new PageBean<User>(curPage,pageSize,count,list);
        return pb;
    }
     //根据uid查询详情
    @Override
    public User queryUserById(String uid) {
        return userDao.queryUserById(uid);
    }
   //添加用户
    @Override
    public boolean addUser(User u) {
        return userDao.addUser(u)>0?true:false;
    }
   //删除用户信息
    @Override
    public boolean deleteUser(String uid) {
        return userDao.deleteUser(uid)>0?true:false;
    }
   //修改用户信息
    @Override
    public boolean update(User u) {
        return userDao.updateUser(u)>0?true:false;

    }
    //
}
